import Mock from 'mockjs'

//商品一级分类
const categoryone = [
  {
    id: 1,
    name: '手机'
  },
  {
    id: 2,
    name: '电脑'
  },
  {
    id: 3,
    name: '平板'
  }
]
Mock.mock('/api/categoryone', 'get', categoryone)

// 商品二级分类
const categorytwo = [
  {
    id: 1,
    datalist: [
      {
        id: 4,
        name: '苹果'
      },
      {
        id: 5,
        name: '华为'
      },
      {
        id: 6,
        name: '小米'
      }
    ]
  },
  {
    id: 2,
    datalist: [
      {
        id: 4,
        name: '惠普'
      },
      {
        id: 5,
        name: '戴尔'
      },
      {
        id: 6,
        name: '联想'
      }
    ]
  },
  {
    id: 3,
    datalist: [
      {
        id: 4,
        name: '荣耀'
      },
      {
        id: 5,
        name: '华为'
      },
      {
        id: 6,
        name: '苹果'
      }
    ]
  }
]
Mock.mock('/api/categorytwo', 'post', (options) => {
  const { id } = JSON.parse(options.body)
  return categorytwo.find((item) => item.id === id).datalist
})

// 商品三级分类
const categorythree = [
  {
    id: 4,
    dataList: [
      {
        id: 7,
        color: '红'
      },
      {
        id: 8,
        color: '橙'
      }
    ]
  },
  {
    id: 5,
    dataList: [
      {
        id: 7,
        color: '黄'
      },
      {
        id: 8,
        color: '绿'
      }
    ]
  },
  {
    id: 6,
    dataList: [
      {
        id: 7,
        color: '蓝'
      },
      {
        id: 8,
        color: '紫'
      }
    ]
  }
]
Mock.mock('/api/categorythree', 'post', (options) => {
  const { id } = JSON.parse(options.body)
  return categorythree.find((item) => item.id === id).dataList
})

// spu商品列表
const spuList = [
  {
    id: 1,
    goodsname: '小米',
    goodsdescribe: '小米·服务至上'
  },
  {
    id: 2,
    goodsname: '华为',
    goodsdescribe: '华为·遥遥领先'
  },
  {
    id: 3,
    goodsname: '苹果',
    goodsdescribe: '苹果·iphone'
  }
]
// 获取spu商品列表
Mock.mock('/api/spuList', 'get', (options) => spuList)
